package shop.up.all.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import shop.up.common.result.Result;
import shop.up.item.client.ItemFeignClient;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author zzc
 * @date 2023/4/2 17:39
 */
@Controller
public class ItemController {

    @Resource
    private ItemFeignClient itemFeignClient;

    /**
     * sku详情页面
     * @param skuId
     * @param model
     * @return
     */
    @RequestMapping("{skuId}.html")
    public String getItem(@PathVariable Long skuId, Model model){
        // 通过skuId 查询skuInfo
        Result<Map<String,Object>> result = itemFeignClient.getItem(skuId);
        // System.out.println(result);
        model.addAllAttributes(result.getData());
        return "item/index";
    }
}
